<template>
  <el-dialog title="会员编辑" :visible.sync="obj.flag" width="50%">
    <span slot="footer" class="dialog-footer">
      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="会员姓名">
          <el-input v-model="form.nickname"></el-input>
        </el-form-item>
        <el-form-item label="会员账户">
          <el-input v-model="form.phone"></el-input>
        </el-form-item>
        <el-form-item label="会员密码">
          <el-input v-model="form.password"></el-input>
        </el-form-item>
        <!-- <el-form-item label="性别">
          <el-radio-group v-model="form.resource">
            <el-radio label="男"></el-radio>
            <el-radio label="女"></el-radio>
          </el-radio-group>
        </el-form-item> -->
        <el-form-item label="状态">
          <el-switch
            v-model="form.status"
            :active-value="1"
            :inactive-value="2"
          ></el-switch></el-form-item
        >{{ form.status }}
      </el-form>

      <el-button @click="can()">取 消</el-button>
      <el-button type="primary" @click="bj()">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
import { memberinfo, memberedit } from "../../../request/api.js";
import { successAlert, warningAlert } from "../../../utils/alert.js";
import { mapActions, mapGetters } from "vuex";
export default {
  props: ["obj"],
  data() {
    return {
      form: {
        nickname: "",
        phone: "",
        password: "",
        status: 1,
      },
    };
  },
  methods: {
    ...mapActions({
      asyncChangeList: "memberList/asyncChangeList",
    }),
    //获取
    huo(uid) {
      memberinfo({ uid: uid }).then((res) => {
        console.log(res);
        this.form = res.data.list;
        this.uid = uid;
      });
    },
    //清空
    empty() {
      this.from = {
        nickname: "",
        phone: "",
        status: 1,
      };
      this.obj.flag = false;
    },
    //取消
    can() {
      this.empty();
    },
    //确定
    bj() {
      console.log(this.form);
      memberedit(this.form).then((res) => {
        if (res.data.code == 200) {
          successAlert(res.data.msg);
          this.empty();
          this.asyncChangeList();
        } else {
          warningAlert(res.data.msg);
        }
      });
    },
  },
  mounted() {},
};
</script>

<style>
</style>